﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Reflection;

namespace Kokomo.Mirror.CliMetadata
{
	class MetadataFieldDescriptor : PropertyDescriptor
	{
		public FieldInfo Field { get; private set; }

		public MetadataFieldDescriptor(FieldInfo field)
			: base(field.Name, (Attribute[])field.GetCustomAttributes(typeof(Attribute), true))
		{
			if (field == null) throw new ArgumentNullException("field");
			this.Field = field;
		}
		public override bool CanResetValue(object component)
		{
			return false;
		}

		public override Type ComponentType
		{
			get { return this.Field.ReflectedType; }
		}

		public override object GetValue(object component)
		{
			return this.Field.GetValue(component);
		}

		public override bool IsReadOnly
		{
			get { return false; }
		}

		public override Type PropertyType
		{
			get { return this.Field.FieldType; }
		}

		public override void ResetValue(object component)
		{
			throw new NotImplementedException();
		}

		public override void SetValue(object component, object value)
		{
			throw new NotImplementedException();
		}

		public override bool ShouldSerializeValue(object component)
		{
			return false;
		}

		public override string DisplayName
		{
			get
			{
				return base.DisplayName;
			}
		}

		public override bool IsBrowsable
		{
			get
			{
				return base.IsBrowsable;
			}
		}

		public override string Description
		{
			get
			{
				return base.Description;
			}
		}

		public override TypeConverter Converter
		{
			get
			{
				return base.Converter;
			}
		}

		protected override Attribute[] AttributeArray
		{
			get
			{
				return base.AttributeArray;
			}
			set
			{
				base.AttributeArray = value;
			}
		}
		public override AttributeCollection Attributes
		{
			get
			{
				return base.Attributes;
			}
		}
		protected override AttributeCollection CreateAttributeCollection()
		{
			return base.CreateAttributeCollection();
		}
		public override string Category
		{
			get
			{
				return base.Category;
			}
		}
		public override object GetEditor(Type editorBaseType)
		{
			return base.GetEditor(editorBaseType);
		}
	}
}
